package com.genexususa.eo.bing.data.results;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.BatchError;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "AdGroupsResult")
public class GxElementsCampaignsResult extends GxGeneralResult {
    @XmlElement(name = "GxCampaignId")
    public long gxCampaignId;
    @XmlElement(name = "BingCampaignId")
    public long bingCampaignId;
    @XmlElementWrapper(name = "AdGroupResultCollection")
    @XmlElement(name = "AdGroupResult")
    public GxElementsAdGroupsResult[] elementsAdGroupsResults;

    public GxElementsCampaignsResult() {
        super();
    }

    public GxElementsCampaignsResult(int resultQuantity) {
        super();
        this.elementsAdGroupsResults = new GxElementsAdGroupsResult[resultQuantity];
    }

    public void addResult(int index, GxElementsAdGroupsResult elementsAdGroupsResult) {
        this.elementsAdGroupsResults[index] = elementsAdGroupsResult;
    }

    public GxElementsAdGroupsResult[] getElementsAdGroupsResults() {
        return elementsAdGroupsResults;
    }

    public void setGxCampaignId(long gxCampaignId) {
        this.gxCampaignId = gxCampaignId;
    }

    public void setBingCampaignId(long bingCampaignId) {
        this.bingCampaignId = bingCampaignId;
    }

    public void addBatchError(BatchError error) {
        this.hasError = true;
        this.elementsAdGroupsResults[error.getIndex()].addBatchError(error);
    }

    public void setError() {
        this.hasError = true;
    }
}
